import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        component: () => import('../pages/MainControl.vue'),
        meta: {
            title: '首页',
        },
        children: []
    }
];

const myRoutes = new VueRouter({
    // mode: 'history',
    base: process.env.VUE_APP_BASE_URL,
    routes
});
/**
 * 路由导航守卫
 */
myRoutes.beforeEach((to, from, next) => {
    const key = localStorage.getItem('member_key');
    if (to.fullPath !== '/') {
        key ? next() : myRoutes.push('/')
    } else {
        next()
    }
});
export default myRoutes
